const settings = require('@/settings')
import Cookies from 'js-cookie'
const TokenKey = settings.tokenKey

export function getToken() {
  return localStorage.getItem(TokenKey)
}

export function setToken(token) {
  return localStorage.setItem(TokenKey, token)
}

export function removeToken() {
  return localStorage.removeItem(TokenKey)
}
export function getCookieToken() {
  return Cookies.get(TokenKey)
}
export function setCookieToken(token) {
  if (process.env.NODE_ENV === 'development') {
    Cookies.set(TokenKey, token)
  } else {
    Cookies.set(TokenKey, token, { path: '/', domain: '' })
  }
}

export function removeCookieToken() {
  if (process.env.NODE_ENV === 'development') {
    return Cookies.remove(TokenKey)
  } else {
    return Cookies.remove(TokenKey, { path: '/', domain: '' })
  }
}
